﻿using System;
using System.Collections.Generic;
using System.Text;
using WAF.Server;
using System.ServiceModel;
using WAF.Server.Ipc;

namespace TestAppServer
{
    class Program
    {
        static AppServerService appServer;
        static ServiceHost host;

        static void Main(string[] args)
        {
            Console.WriteLine("Starting AppServer");

            appServer = new AppServerService();
            Uri uri = new Uri("net.pipe://localhost/2WAF/IISTests");
            NetNamedPipeBinding pipesBinding = new NetNamedPipeBinding();
            pipesBinding.TransferMode = TransferMode.Buffered;
            pipesBinding.Security.Mode = NetNamedPipeSecurityMode.None;

            host = new ServiceHost(appServer);
            host.AddServiceEndpoint(typeof(IAppServerIpcContract), pipesBinding, uri);
            host.Open();
           
            Console.WriteLine("AppServer started press 's' to stop");
            while (Console.ReadKey().KeyChar != 's') { }
            Console.WriteLine();
            Console.WriteLine("Stopping AppServer");
            host.Close();
            appServer.Dispose();
            Console.WriteLine("AppServer stopped");
        }
    }
}
